#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

bool judge(ll n){
    while(n){
        if(n%10==4)return false;
        n/=10;
    }
    return true;
}

int main()
{
    IOS;
    ll ans=0;
    for(ll i=10000;i<100000;i++){
        if(judge(i))ans++;
    }
    cout<<ans<<endl;
    getchar();
    getchar();
    return 0;
}
